﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KMFrame.Core;
using SzCourt.Logic.BLL;
using KMFrame.Permission.Util;

namespace SzCourt.WebSite.facebook
{
    public partial class index : System.Web.UI.Page
    {
        public int PageIndex = 1;
        public int PageSize = 10;
        public int TotalPage = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (SessionBox.CheckUserSession())
                {
                    this.divSendMessage.Attributes.Add("class", "");
                    this.emly.Attributes.Add("class", "right g_dn");
                    this.ahreftblmes.Attributes.Add("class", "right");
                }
                else
                {
                    this.emly.Attributes.Add("class", "right");
                    this.ahreftblmes.Attributes.Add("class", "right g_dn");
                }
                getList();
            }
        }

        private void getList()
        {
            this.PageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);

            PageParam param = new PageParam();
            param.PageIndex = this.PageIndex;
            param.PageSize = this.PageSize;

            int UserID = 0;
            if (SessionBox.CheckUserSession())
            {
                UserID = SessionBox.GetUserSession().UserID;
            }
            IdeasBox bll = new IdeasBox();
            PageResult result = (PageResult)bll.GetIdeasBoxPage(param, UserID);

            if (result != null)
            {
                this.rptDataList.DataSource = result.ResultList;
                this.rptDataList.DataBind();

                this.pager1.RecordCount = result.TotalCount;
                this.pager1.TotalPage = result.PageCount;
                this.pager1.PageIndex = this.PageIndex;
                this.pager1.PageSize = this.PageSize;
                this.pager1.LinkUrl = "/facebook/index.aspx?PageIndex=" + this.PageIndex.ToString();
                this.pager1.IsResult = false;

                if (result.TotalCount == 0)
                {
                    this.noData.Attributes.Add("class", "mgn10 g_tc");
                }
            }
            else
            {
                this.noData.Attributes.Add("class", "mgn10 g_tc");
            }
        }
    }
}
